package com.zhiche.lisa.bms.service.charge;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.zhiche.lisa.bms.dao.model.charge.ChargeOffRule;
import com.zhiche.lisa.bms.dao.model.fee.FeePayable;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 出账规则 服务类
 * </p>
 *
 * @author liuanshun
 * @since 2018-11-02
 */
public interface ChargeOffRuleService extends IService<ChargeOffRule> {
    /**
     * 获取出账规则列表
     *
     * @param condition
     * @return
     */
    List<ChargeOffRule> selectChargeOffRuleList(Map<String, Object> condition);

    /**
     * 获取出账规则分页信息
     *
     * @param pageParam
     * @return
     */
    Page<ChargeOffRule> selectChargeOffRulePage(Page<ChargeOffRule> pageParam);

    /**
     * 新增单条出账规则
     *
     * @param addChargeOffRule
     * @return
     */
    ChargeOffRule insertChargeOffRule(ChargeOffRule addChargeOffRule);

    /**
     * 根据车队寻找对应出账规则
     *
     * @param fleetId
     * @param condition
     * @return
     */
    ChargeOffRule selectChargeOffRuleByFleetId(Long fleetId, Map<String, Object> condition);

    /**
     * 修改单条出账规则
     *
     * @return
     */
    ChargeOffRule updateChargeOffRule(ChargeOffRule newChargerOffRule);

    /**
     * 启用出账规则
     *
     * @param id
     * @return
     */
    ChargeOffRule openChargeOffRule(Long id);

    /**
     * 禁用出账规则
     *
     * @param id
     * @return
     */
    ChargeOffRule closeChargeOffRule(Long id);

    /**
     * 获取可以出账的出账规则
     *
     * @return
     */
    List<ChargeOffRule> getArePayableChargeOffRules();

    /**
     * 出账
     *
     * @param id
     * @param fullParam
     * @return
     */
    ChargeOffRule payable(Long id, ChargeOffRule fullParam, EntityWrapper<FeePayable> feeSourceInitEntity);

    /**
     * 根据账款生成对应账单
     *
     * @param feePayables
     */
    void createBillAndDetailByFees(List<FeePayable> feePayables, String userName);

    /**
     * 验证账期
     *
     * @param fleetId
     * @param checkType
     * @return
     */
    ChargeOffRule checkPayDays(Long fleetId, String checkType);

    /**
     * 根据车队集合和有效期判断是否存在出账规则
     *
     * @param fleetIdList
     * @param effectDate
     * @param invalidDate
     * @return
     */
    Integer getExistCount(List<String> fleetIdList, Date effectDate, Date invalidDate);
}
